# from QTimerTest import 
# from vnpy.trader.ui import MainWindow, create_qapp
import sys
from PyQt5.QtWidgets import QApplication,QMainWindow
from PyQt5.QtCore import QTimer
from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setMaximumSize(QtCore.QSize(200, 16777215))
        self.pushButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.pushButton)
        self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
        self.textEdit.setMaximumSize(QtCore.QSize(16777215, 200))
        self.textEdit.setObjectName("textEdit")
        self.verticalLayout.addWidget(self.textEdit)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 18))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "PushButton"))

class TimerTest(QMainWindow,Ui_MainWindow):
    def __init__(self,parent=None):
        super(TimerTest,self).__init__(parent)
        self.setupUi(self)
        self.timer=QTimer()
        self.Num=0
        self.pushButton.clicked.connect(self.timerStart)
    def timerStart(self):
        self.timer.timeout.connect(self.DisplayNum)
        self.textEdit.clear()
        self.Num=0
        self.timer.start(1000)
    def DisplayNum(self):
        if self.Num<10:
            self.textEdit.append(str(self.Num))
            self.Num+=1
        else:
            self.textEdit.append('Done!')
            self.timer.stop()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ui=TimerTest()
    ui.show()
    sys.exit(app.exec_())
